package com.yiyi.credit.manage.sso.common;

import sun.misc.BASE64Encoder;

import java.security.MessageDigest;


public class MD5Util {

    public static String encoderByMd5(String str) throws Exception {
        //确定计算方法
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        BASE64Encoder base64en = new BASE64Encoder();
        //加密后的字符串
        return base64en.encode(md5.digest(str.getBytes("utf-8")));
    }



    public static boolean checkPassword(String newPsw, String oldPsw) throws Exception {

        return encoderByMd5(newPsw).equals(oldPsw);
    }

}
